//Direct3D Framework Header File
//Declares the Framework for DirectX
//Jeffrey Denton	January 11, 2011
#pragma once
#include "Globals.h"
#include "GameHandler.h"
//#include "AllDynamics.h"
#include "Camera.h"
#include "Input.h"

#define DXTEXTURE LPDIRECT3DTEXTURE9
#define ID3DDEVICE IDirect3DDevice9

class Graphics
{
protected:
	//DirectX Key Objects
	IDirect3DDevice9*		mD3DDevice;
	ID3DXSprite*			mD3DSprite;
	HWND					mhWnd;

	//Object Placement Matrices
	D3DXMATRIX				mWorldMat;	//World
	D3DXMATRIX				mTransMat;	//Translation
	D3DXMATRIX				mRotMat;	//Rotation
	D3DXMATRIX				mScaleMat;	//Scale
	D3DXMATRIX				mViewMat;	//View
	D3DXMATRIX				mPerspMat;	//Perspective

	/*VARIABLES*/
	D3DPRESENT_PARAMETERS	D3D_PP;						//Presentation Parameters

	/*3D*/
	char*					m_cszMeshNames[D3OBJ_SIZE];	//Name:  Meshes
	char*					m_cszTexNames [D3OBJ_SIZE];	//Name:	 Textures
	ID3DXMesh*				mdMeshes	  [D3OBJ_SIZE];	//Index: Meshes
	DXTEXTURE				mdTextures	  [D3OBJ_SIZE];	//Index: Textures
	D3DXVECTOR3				mdTexCenter	  [D3OBJ_SIZE];	//Index: Texture Center Coordinates
	D3DXIMAGE_INFO			mdImageInfo	  [D3OBJ_SIZE];	//Index: ImageInfo
	D3DMATERIAL9			m_dmDefaultMaterial;


	//=====LIGHT
	D3DLIGHT9				mDefaultLight;		


	//=====CAMERA
	Camera					GameCamera;

public:
	
	//=====CONSTRUCTORS
	Graphics();														//Default Constructor
	virtual ~Graphics ();											//Default Destructor
	//=====INITIALIZE
	bool Initialize(HWND, HINSTANCE, bool);							//Initialize DirectX
	bool InitTextures();
	bool InitMeshes();
	bool InitDevice(HWND,bool);
	void InitLight();
	//=====EXTERNAL DATA READING
	void LoadTexture(int, string);
	void LoadMeshFile(const char*, ID3DXMesh*&);	
	//=====UPDATE
	void Update();													//Update DirectX
	void CheckDevice();
	//=====RENDER
	bool Draw(DrawList& drawlist);									//Draw Objects to the Screen
	//=====ACCESSORS
	ID3DDEVICE*	 DXDevice();										//Returns a pointer to the DirectX Device
	ID3DXSprite* DXSprite();										//Returns a pointer to the DirectX Sprite
	ID3DXMesh*	 GetMeshByIndex		(unsigned index);
	DXTEXTURE	 GetTextureByIndex	(unsigned index);
	DXTEXTURE	 GetTexture(int I);		//Returns Texture at index I
		inline static Graphics* Into()      
	{static Graphics engine;return &engine;}
	//=====MUTATORS
	//=====SHUTDOWN
	bool Shutdown();													//Release DirectX Objects

};

